package com.cictec.middleware.gps.engine.utils;

import com.cictec.middleware.commons.utils.PMSUtils;
import com.cictec.middleware.core.pojo.ESPositionEntity;
import com.cictec.middleware.gps.engine.TimingPoint;


/**
 * ES数据模型转换器
 * @author ql
 *
 */
public class ESPositionEntityConvertUtils {
	

	/**
	 *  时序节点转换为 位置节点
	 * @param timingPoint
	 * @return 
	 */
	public static ESPositionEntity convertToESTimingPointToPosiston(TimingPoint timingPoint) {
		ESPositionEntity busPosition = new ESPositionEntity();
		busPosition.setPosUuid(PMSUtils.getUUID());
		// 线路id
		busPosition.setLineUuid(timingPoint.getLineUuid());
		// 线路类型
		busPosition.setLineType(timingPoint.getLineType());
		// 车辆ID
		busPosition.setBusUuid(timingPoint.getBusUuid());
		// 设备ID
		busPosition.setDevUuid(timingPoint.getDevUuid());
		// 站点编号 以站点序列号替换 站点ID
		busPosition.setSationUuid(timingPoint.getStationUuid());
		// 站点名称
		busPosition.setSationName(timingPoint.getStationName());
		// 司机卡号
		busPosition.setDrvIcCard(timingPoint.getDriverIccard());
//		// 司机名称
		busPosition.setDriverName(timingPoint.getDriverName());
		// 司机uuid
		busPosition.setDriverUuid(timingPoint.getDriverUuid());
		// 经度
		busPosition.setLat(timingPoint.getLatitude());
		// 纬度
		busPosition.setLng(timingPoint.getLongitude());
		// 速度
		busPosition.setBusSpeed(timingPoint.getSpeed());
		// 运营状态
		busPosition.setRealTimeStatus(timingPoint.getStatusInOperateTime());
		// 采集时间
		busPosition.setGatherTime(timingPoint.getTime());
		// 是否漂移
		busPosition.setIsOffset(timingPoint.getStatusDrift());
		// 方位角
		busPosition.setCursorOverGround(timingPoint.getCounrse());		
		// 是否在站内
		busPosition.setPosIsInStation(timingPoint.getStationEnterOut());
		// 相对位置
		String positionRate = timingPoint.getPositionRate();
		busPosition.setRelativeLocation(Double.parseDouble(PMSUtils.isEmpty(positionRate) ? "0":positionRate));
		// 报警
		busPosition.setAllAlarms(timingPoint.getAllAlarms());
		
		return busPosition;
	}
}
